package weekMatch.one_344;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_01 {
    public static void main(String[] args) {

    }
    private static int[] distinctDifferenceArray(int[] nums) {
        if (nums.length == 0)
            return new int[0];
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        int n = nums.length;
        int[] pre = new int[n];
        int[] aft = new int[n];
        for (int i = 0; i < n; i++) {
            set1.add(nums[i]);
            pre[i] = set1.size();
        }
        for(int i = n - 1;i >= 0;i--){
            set2.add(nums[i]);
            aft[i] = set2.size();
        }
        int[] ans = new int[n];
        for (int i = 0; i < n - 1; i++) {
            ans[i] = pre[i] - aft[i + 1];
        }
        ans[n - 1] = pre[n - 1];
        return ans;
    }
}
